/**
 * 文章相关接口
 * 
 */
 import request from '@/utils/request.js'
// 获取文章列表

const getArticles = (queryInfo) =>{
    return request.get('/v1_0/articles',{params:queryInfo})
}

// 获取文章详情

const getArticleDetail = (articleId)  =>  {
    return request({
        url: `/v1_0/articles/${articleId}`,
        method: 'GET'
    })
}

// 对文章点赞

const addArticleLike = (articleId) =>{
    return request({
        url: '/v1_0/article/likings',
        method: 'POST',
        data: {
            target: articleId
        }
    })
}

// 对文章取消点赞
const deleteArticleLike = (articleId)  => {
    return request({
        url: `/v1_0/article/likings/${articleId}`,
        method: 'DELETE'
    })
}

// 收藏文章

const addCollectArticle = (articleId) => {
    return request({
        url: '/v1_0/article/collections',
        method: 'POST',
        data: {
            target: articleId
        }
    })
}

// 取消收藏文章

const deleteCollectArticle = (articleId) => {
    return request({
        url: `/v1_0/article/collections/${articleId}`,
        method: 'DELETE'
    })
}

// 拉黑文章

const defriendArticle = (articleId) => {
    return request({
        url: '/v1_0/article/dislikes',
        method: 'POST',
        data:{
            target: articleId
        }
    })
}

// 反馈文章

const reportsArticle = (articleId,type) =>{
    return request({
        url: '/v1_0/article/reports',
        method: 'POST',
        data: {
            target:articleId,
            type
        }
    })
}
export {
    getArticles,
    getArticleDetail,
    addArticleLike,
    deleteArticleLike,
    addCollectArticle,
    deleteCollectArticle,
    defriendArticle,
    reportsArticle
}